import type { FormItem } from '@com/Form/index';
import type { TableConfigItem } from '@com/Table/index';
import type { ListRes, ObjectRes } from '@u/request/type/index';
import { Ref } from 'vue';

//useBaseTable 入参
export interface UseTableParam {
  tableRef?: Ref<HTMLElement | null>;
  searchFormConifg: Ref<FormItem[]>;
  tableConifg: Ref<TableConfigItem[]>;
  getDataAPI(parma: object): Promise<ListRes>;
  addDataAPI?(parma: object): Promise<ObjectRes>;
  editDataAPI?(parma: object): Promise<ObjectRes>;
  delDataAPI?(id: number | string): Promise<ObjectRes>;
}

//useBaseTable 出参
export interface UseTableReturn {
  paginationProps: object;
  formDialogProps: Ref<DialogProps>;
  viewFormDialogProps: Ref<DialogProps>;
  tableData: Ref<object[]>;
  searchFormData: object;
  addHandle(): void;
  editHandle(formData: Record<string, unknown>, index?: number): void;
  getTableList(): void;
  searchHandle(): void;
  resetHandle(): void;
  submit(formData: Record<string, unknown>): void;
  delHandle(id: number | string): void;
  exportHandle(): void;
  handleSizeChange(val: number): void;
  handleCurrentChange(val: number): void;
  handleOpenView(formData: Record<string, unknown>): void;
}

// UseWirteTable出参
export interface UseWirteTableReturn extends Omit<UseTableReturn, 'formDialogProps'> {
  editRowIndexArr: Ref<number[]>;
}

export interface DialogProps {
  dialogVisible: boolean;
  title: string;
  formData: object;
  type?: string;
}
